package com.juyu.miliao.api.controller;


import com.juyu.miliao.api.domain.RedPacket;
import com.juyu.miliao.api.service.LuckyWheelService;
import com.juyu.miliao.common.domain.Subject;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 幸运转盘
 * wbf
 */
@RestController
@RequestMapping("/luckyWheel")
public class LuckyWheelController {
    @Resource
    private LuckyWheelService luckyWheelService;

    @PostMapping()
    public RedPacket computeRedPacket(Authentication token, @RequestParam("costType") Integer costType) {
        Subject subject = (Subject) token.getPrincipal();
        return luckyWheelService.computeLuckyWheel(costType, subject.getId());
    }

}
